/*
 * @Descripttion:
 * @version:
 * @Author: 夜殇
 * @Date: 2020-04-15 14:36:43
 * @LastEditors: 夜殇
 * @LastEditTime: 2020-06-12 12:25:24
 */

const mongoose = require('mongoose')
const Schema = mongoose.Schema

const userSchema = new Schema({
  email: {
    type: String,
    required: true
  },
  password: {
    type: String,
    required: true
  },
  userName: {
    type: String,
    required: false
  },
  nickName: {
    type: String,
    required: true
  },
  avatar: {
    type: String,
    required: false
  },
  identity: {
    type: String,
    required: true
  },
  gender: {
    type: String,
    required: false
  },
  age: {
    type: Number,
    required: false
  },
  personalized: {
    // 个性签名
    type: String,
    required: false,
    default: '书山有路勤为径，学海无涯苦作舟'
  },
  friends: {
    // 好友列表
    type: Array,
    required: false,
    default: [
      {
        email: '',
        addDate: '',
        userName: ''
      }
    ]
  },
  applyCourse: {
    // 已购买课程列表
    type: Array,
    required: false,
    default: []
  },
  shopCart: {
    // 购物车列表
    type: Array,
    required: false,
    default: []
  },
  collect: {
    // 收藏夹列表
    type: Array,
    required: false,
    default: []
  },
  myCourseNum: {
    // 用户购买的课程总量
    type: Number,
    required: false,
    default: 0
  }
})

module.exports = mongoose.model('User', userSchema)
